﻿Option Strict On

Imports System.Collections.Generic
Imports System.Text


Namespace FTP
    ''' <summary>
    ''' Thread safe FtpResponse queue object.
    ''' </summary>
    Friend Class FtpResponseQueue
        Private _queue As New Queue(Of FtpResponse)(10)

        ''' <summary>
        ''' Gets the number of elements contained in the FtpResponseQueue.
        ''' </summary>
        Public ReadOnly Property Count() As Integer
            Get
                SyncLock Me
                    Return _queue.Count
                End SyncLock
            End Get
        End Property





        ''' <summary>
        ''' Adds an Response object to the end of the FtpResponseQueue.
        ''' </summary>
        ''' <param name="item">An FtpResponse item.</param>
        Public Sub Enqueue(ByVal item As FtpResponse)
            SyncLock Me
                _queue.Enqueue(item)
            End SyncLock
        End Sub

        ''' <summary>
        ''' Removes and return the FtpResponse object at the beginning of the FtpResponseQueue.
        ''' </summary>
        ''' <return>FtpResponse object at the beginning of the FtpResponseQueue</return>
        Public Function Dequeue() As FtpResponse
            SyncLock Me
                Return _queue.Dequeue()
            End SyncLock
        End Function





    End Class
End Namespace